package leetcode_501_600;

import java.util.List;

public class LeeCode_559 {
    public static void main(String[] args) {

    }
    private static int maxDepth(Node root) {
        if (root == null)
            return 0;
        return dfs(root, 1);
    }
    private static int dfs(Node node, int depth){
        if (node.children == null || node.children.size() == 0){
            return depth;
        }
        int max  =0;
        for (Node child : node.children) {
            max = Math.max(max, dfs(child, depth + 1));
        }
        return max;
    }
    static class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    }
}
